<script setup lang="ts">
import { ref } from "vue";
import { default as vElTableInfiniteScroll } from "el-table-infinite-scroll";

defineOptions({
  name: "InfiniteScroll"
});

const dataTemplate = [{
  RMSSD: "22",
  SDNN: "33",
},{
  RMSSD: "212",
  SDNN: "313",
},{
  RMSSD: "322",
  SDNN: "433",
}]

const data = ref([]);
const disabled = ref(false);
const page = ref(0);
const total = ref(10);

const load = () => {
  if (disabled.value) return;

  page.value++;
  if (page.value <= total.value) {
    data.value = data.value.concat(dataTemplate);
  }

  if (page.value === total.value) {
    disabled.value = true;
  }
};
</script>

<template>
  <div shadow="never">
 
    <div>
      
      <el-table
        v-el-table-infinite-scroll="load"
        :data="data"
        :infinite-scroll-disabled="disabled"
        height="435px"
      >
        <el-table-column type="index" />
        <el-table-column prop="RMSSD" label="RMSSD" />
        <el-table-column prop="SDNN" label="SDNN" />
      </el-table>
    </div>
  </div>
</template>
